#include "formulalistmodel.h"
#include "ui/body_mass_index_formwidget.h"
#include "ui/glasgow_coma_scale_formwidget.h"

FormulaListModel::FormulaListModel(QObject *parent) :
        QAbstractListModel(parent)
{
}
void FormulaListModel::loadForms()
{
    mForms.clear();


    mForms.append(new Body_Mass_Index_FormWidget);
    mForms.append(new Glasgow_Coma_Scale_FormWidget);




}

QVariant FormulaListModel::data(const QModelIndex &index, int role) const
{

    if ( role != Qt::DisplayRole)
        return QVariant();

    else
        return mForms[index.row()]->formula()->name();

}
int FormulaListModel::rowCount(const QModelIndex &parent) const
{

    return mForms.count();

}
AbstractFormWidget * FormulaListModel::formWidget(const QModelIndex& index)
{

    if (index.isValid())
        return mForms[index.row()];

    else
        return NULL;

}
